#include"processbar.h"
#include<string.h>
#include<unistd.h>
char bar[NUM]={0};
char* lable="|/-\\";


void jp(tp cp)
{
	int a=1000;
	int b=0;
	while(b<=a)
	{
		usleep(5000);
		cp(b*100/1000);
		b+=10;
	}
	printf("\n");
}
void processbar(int rate)
{
	if(rate<0||rate>100) return;
	int len=strlen(lable);
	printf("[%-100s][%2d%%][%c]\r",bar,rate,lable[rate%len]);
	fflush(stdout);	
	bar[rate++]='-';
	if(rate<100)
	bar[rate]='>';
	usleep(100000);
}
void clear()
{
	memset(bar,'\0',sizeof(bar));
}
